// app.js
App({
  // onReady: function() {
  //   // 获取胶囊按钮位置信息
  //   console.log('capsule.top'); 
  //   const capsule = wx.getMenuButtonBoundingClientRect();
  //   console.log(capsule.height);
  //   console.log(capsule.top); 
  //   this.setData({
  //     // 设置圆形 DOM 的样式
  //     circleStyle: `width: ${capsule.height}px; height: ${capsule.height}px; top: ${capsule.top}px; right: 5rpx; position: fixed; border-radius: 50%; background-color: #FF0000;` // 样式根据实际需求设定
  //   });
  // },
  onLaunch() {
      // 获取胶囊按钮位置信息
      console.log('capsule.top'); 
      const capsule = wx.getMenuButtonBoundingClientRect();
      console.log(capsule); 
      this.globalData.capsule = capsule 

      let that = this
      function getNavigationBarHeight() {
        const systemInfo = wx.getSystemInfoSync();
        const statusBarHeight = systemInfo.statusBarHeight;
        that.globalData.statusBarHeight = statusBarHeight
        console.log('statusBarHeight:', statusBarHeight);
        const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
        const navigationBarHeight = (menuButtonInfo.bottom - menuButtonInfo.top) + (menuButtonInfo.top - statusBarHeight) * 2;
        return navigationBarHeight;
      }
      
      const navBarHeight = getNavigationBarHeight();
      console.log('导航栏高度:', navBarHeight);
      this.globalData.navBarHeight = navBarHeight

    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null
  }
})
